package engine.graphics.vfx
{
	import away3d.bounds.*;
	import away3d.core.base.*;
	import away3d.core.managers.*;
	import away3d.entities.*;
	
	import engine.asset.*;
	import engine.core.*;
	import engine.graphics.away3d.*;
	import engine.loaders.*;
	import engine.math.*;
	
	public class RxWorldMeshFX extends RxWorldMeshBaseFX
	{
		private var m_mesh:Mesh;
		private var m_stage3DProxy:Stage3DProxy;
		private var m_model:RxAssetModel;
		private var m_onLoadListener:Function;
		private static var s_pool:RxObjectPool = null;
		
		public function RxWorldMeshFX(mesh:Mesh, proxy:Stage3DProxy)
		{
			InitMeshFX(mesh, proxy);
		}
		
		private function InitMeshFX(mesh:Mesh, proxy:Stage3DProxy) : void
		{
			this.m_stage3DProxy = proxy;
			this.m_model = null;
			this.m_onLoadListener = null;
			this.SetMesh(mesh);
		}
		
		public function SetMesh(mesh:Mesh) : void
		{
			var subMeshes:Vector.<SubMesh> = null;
			var geometry:SubGeometry = null;
			var material:RxMaterial = null;
			this.m_mesh = mesh;
			if (this.m_mesh)
			{
				subMeshes = this.m_mesh.subMeshes;
				if (subMeshes.length > 0)
				{
					geometry = subMeshes[0].subGeometry;
					material = RxMaterial(subMeshes[0].material);
					m_texture = material.GetTexture();
				}
			}
		}
		
		public static function CreatePool(initSize:uint, growSize:uint) : void
		{
			var allocFunc:* = function () : Object
			{
				return new RxWorldMeshFX(null, null);
			};
			
			s_pool = new RxObjectPool(allocFunc, null, initSize, growSize, RxWorldMeshFX);
		}
	}
}